import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/Layout.vue'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '',
        redirect: '/home',
        meta: { hidden: true },
      },
      {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/home/Home.vue'),
        meta: {
          title: '首页',
          icon: 'home', // 建议添加图标配置
        },
      },
      {
        path: '/cart',
        name: 'Cart',
        component: () => import('@/views/cart/Cart.vue'),
        meta: {
          title: '购物车',
          hidden: true, // 隐藏菜单
        },
      },
      {
        path: '/example',
        name: 'Example',
        component: () => import('@/layout/components/BlankLayout.vue'), // 用于嵌套路由的空白布局
        meta: {
          title: '示例',
        },
        redirect: '/example/index', // 重定向到默认子路由
        children: [
          {
            path: '/example/index',
            name: 'ExampleIndex',
            component: () => import('@/views/example/index.vue'),
            meta: {
              title: '示例',
            },
          },
          {
            path: '/dictManagement',
            name: 'dictManagement',
            component: () => import('@/views/example/DictManagement.vue'),
            meta: {
              title: '字典管理页面',
            },
          },
          {
            path: '/page2',
            name: 'Page2',
            component: () => import('@/views/example/page2.vue'),
            meta: {
              title: '页面2',
            },
          },
        ],
      },
      {
        path:'/service/love-wall',
        name: 'Wall',
        component: () => import('@/views/wall/Index.vue'),
        meta:{
          title: '墙',
          hidden: true, // 隐藏菜单
        }
      }
      // 其他子路由...

    ],
  },
  // 404页面
  {
    path: '/:pathMatch(.*)*',
    name: 'NotFound',
    component: () => import('@/views/error/NotFound.vue'),
    meta: { hidden: true },
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/Login.vue'),
    meta: { hidden: true },
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/login/components/Register.vue'),
  },
  {
    path: '/task/detail/:id',
    name: 'TaskDetail',
    component: () => import('@/views/task/components/Detail.vue'),
    meta: {
      title: '任务详情',
      hidden: true, // 隐藏菜单
    }
  },
  {
    path: '/news/detail/:id',
    name: 'newsDetail',
    component: () => import('@/views/news/components/Detail.vue'),
    meta: {
      title: '新闻详情',
      hidden: true, // 隐藏菜单
    }
  },
   {
    path: '/goods/detail/:id',
    name: 'goodsDetail',
    component: () => import('@/views/market/components/Detail.vue'),
    meta: {
      title: '商品详情',
      hidden: true, // 隐藏菜单
    }
  },
   {
    path: '/activity/detail/:id',
    name: 'activityDetail',
    component: () => import('@/views/campaign/components/Detail.vue'),
    meta: {
      title: '活动详情',
      hidden: true, // 隐藏菜单
    }
  },
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
})

export default router
